package cn.wolfcode.controller;


import cn.wolfcode.domain.*;
import cn.wolfcode.query.DestinationQuery;
import cn.wolfcode.query.TravelQueryObject;
import cn.wolfcode.service.IDestinationService;
import cn.wolfcode.service.IRegionService;
import cn.wolfcode.service.IStrategyService;
import cn.wolfcode.service.ITravelService;
import cn.wolfcode.util.JsonResult;
import org.springframework.data.domain.Page;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Description: 前后端分离目的地控制器类
 * @Author: 伍家钰
 * @Date: 2020/8/11 18:53
 * @Version: 1.0
 */
@RestController
@RequestMapping("destinations")
public class DestinationController {
    @Resource
    private IDestinationService destinationService;
    @Resource
    private IRegionService regionService;
    @Resource
    private IStrategyService strategyService;
    @Resource
    private ITravelService travelService;

    /**
     * 热门区域查询并排序(前端目的地要显示)
     *
     * @return
     */
    @RequestMapping("hotRegion")
    public Object hotRegion() {
        List<Region> list = regionService.hotRegion();
        return JsonResult.success(list);
    }

    /**
     * 查看热门区域的目的地
     *
     * @return
     */
    @RequestMapping("search")
    public Object search(String regionId) {
        List<Destination> list = destinationService.queryDestByRefIdsForApi(regionId);
        return JsonResult.success(list);
    }

    /**
     * 前端目的地的吐司查询
     *
     * @return
     */
    @RequestMapping("toasts")
    public Object toasts(String destId) {
        List<Destination> list = destinationService.queryToast(destId);
        return JsonResult.success(list);
    }

    /**
     * 前端目的地的概况查询
     *
     * @return
     */
    @RequestMapping("catalogs")
    public Object catalogs(String destId) {
        List<StrategyCatalog> list = destinationService.queryCatalogs(destId);
        return JsonResult.success(list);
    }

    /**
     * 点击量前3的攻略文章
     *
     * @return
     */
    @RequestMapping("strategies/viewnumTop3")
    public Object strategyViewnumTop3(String destId) {
        List<Strategy> list = strategyService.queryViewnumTop3(destId);
        return JsonResult.success(list);
    }

    /**
     * 点击量前3的游记文章
     *
     * @return
     */
    @RequestMapping("travels/viewnumTop3")
    public Object travelsViewnumTop3(String destId) {
        List<Travel> list = travelService.queryViewnumTop3(destId);
        return JsonResult.success(list);
    }

    /**
     * 查询全部目的地
     *
     * @return
     */
    @RequestMapping("list")
    public Object list() {
        List<Destination> list = destinationService.list();
        return JsonResult.success(list);
    }

}
